package cn.wolfcode.shop.service.impl;

import cn.wolfcode.shop.domain.Property;
import cn.wolfcode.shop.domain.PropertyValue;
import cn.wolfcode.shop.mapper.PropertyValueMapper;
import cn.wolfcode.shop.service.IPropertyValueService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by wolfcode on 2018/8/17.
 */
@Service@Transactional
public class PropertyValueServiceImpl implements IPropertyValueService {
    @Autowired
    private PropertyValueMapper propertyValueMapper;

    public List<PropertyValue> queryByPropertyId(Long propertyId) {
        return propertyValueMapper.queryByPropertyId(propertyId);
    }

    public void saveOrUpdateBatch(List<PropertyValue> propertyValueList) {
        for(PropertyValue pv:propertyValueList){
            if(pv.getId()==null){
                propertyValueMapper.insert(pv);
            }else{
                propertyValueMapper.updateByPrimaryKey(pv);
            }
        }
    }

    public void delete(Long propertyValueId) {
        propertyValueMapper.deleteByPrimaryKey(propertyValueId);
    }
}
